package sample.entity;

import sample.listener.InfoListener;

import java.util.EventObject;

/**
 * 作者：w on 2021-08-06.
 * 邮箱：y141111@126.com
 * 版本：v1.0
 * @Description: 设备信息改变的事件实体
 * 每次我监听的对象（testListenerExecuter ）改变的时候，都会把他的改变传递给我（InfoEvent ），我在把改变传递给需要这个改变的地方（run类）。
 */
public class InfoEvent extends EventObject {
    private Object source;  // 监听的对象
    private String name;
    private double  x;   // 监听的变量 相对坐标X
    private double  y;   // 监听的变量 相对坐标y
    private double  speed;   // 监听的变量 速度
    private double  angle;   // 监听的变量 航向角
    private double  state;   // 监听的变量 差分状态
    private double  difNum;   // 监听的变量 差分数量
    private double  GPGGAX;   // 监听的变量 纬度
    private double  GPGGAY;   // 监听的变量 经度
    private double  errNum;   // 监听的变量 误差值
    private double  radarNum;   // 监听的变量 雷达距离


    /**
     * Constructs a prototypical Event.
     *
     * @param source The object on which the Event initially occurred. 监听的对象
     * @throws IllegalArgumentException if source is null.
     */
    public InfoEvent(Object source) {
        super(source);
    }

    @Override
    public Object getSource() {
        return source;
    }

    public String getName(){
        return name;
    }

    public double getX(){
        return x;
    }

    public double getY() {
        return y;
    }

    public double getSpeed() {
        return speed;
    }

    public double getAngle() {
        return angle;
    }

    public double getState() {
        return state;
    }

    public double getDifNum() {
        return difNum;
    }

    public double getGPGGAX() {
        return GPGGAX;
    }

    public double getGPGGAY() {
        return GPGGAY;
    }

    public double getErrNum() {
        return errNum;
    }

    public double getRadarNum() {
        return radarNum;
    }

    public void setSource(Object source) {
        this.source = source;
    }

    public void setName(InfoListener infoListener, InfoEvent infoEvent, String name){
        this.name = name;
        infoListener.updateEvent(infoEvent);
    }

    public void setX(InfoListener infoListener, InfoEvent infoEvent, double x){
        this.x = x;
        infoListener.updateEvent(infoEvent);
    }

    public void setY(InfoListener infoListener, InfoEvent infoEvent, double y) {
        this.y = y;
        infoListener.updateEvent(infoEvent);
    }

    public void setSpeed(InfoListener infoListener, InfoEvent infoEvent, double speed) {
        this.speed = speed;
        infoListener.updateEvent(infoEvent);
    }

    public void setAngle(InfoListener infoListener, InfoEvent infoEvent, double angle) {
        this.angle = angle;
        infoListener.updateEvent(infoEvent);
    }

    public void setState(InfoListener infoListener, InfoEvent infoEvent, double state) {
        this.state = state;
        infoListener.updateEvent(infoEvent);
    }

    public void setDifNum(InfoListener infoListener, InfoEvent infoEvent, double difNum) {
        this.difNum = difNum;
        infoListener.updateEvent(infoEvent);
    }

    public void setGPGGAX(InfoListener infoListener, InfoEvent infoEvent, double GPGGAX) {
        this.GPGGAX = GPGGAX;
        infoListener.updateEvent(infoEvent);
    }

    public void setGPGGAY(InfoListener infoListener, InfoEvent infoEvent, double GPGGAY) {
        this.GPGGAY = GPGGAY;
        infoListener.updateEvent(infoEvent);
    }

    public void setErrNum(InfoListener infoListener, InfoEvent infoEvent, double errNum) {
        this.errNum = errNum;
        infoListener.updateEvent(infoEvent);
    }

    public void setRadarNum(InfoListener infoListener, InfoEvent infoEvent, double radarNum) {
        this.radarNum = radarNum;
        infoListener.updateEvent(infoEvent);
    }
}
